//
//  TJHomeDetaiCell.m
//  Teleport
//
//  Created by hc-101 on 2020/6/16.
//  Copyright © 2020 xtjun. All rights reserved.
//

#import "TJHomeDetaiCell.h"


@interface TJHomeDetaiCell()


@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UILabel *numberValueLabel;
@property (strong, nonatomic) UILabel *stateValueLabel;
@property (strong, nonatomic) UILabel *timeValueLabel;


@end


@implementation TJHomeDetaiCell

- (void)settingSubView {
    
    
    _titleLabel = [UILabel lableWithSuperView:self.contentView font:MediumFont(15) color:UIColor_Hex(0x262626) title:@"" textAlignment:NSTextAlignmentLeft];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(16);
        make.top.offset(16);
    }];
    
    UILabel *numberLabel = [UILabel lableWithSuperView:self.contentView font:UIFont_Px(14) color:UIColor_Hex(0x656565) title:@"数量".localizedString textAlignment:NSTextAlignmentLeft];
    [numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleLabel);
        make.top.equalTo(_titleLabel.mas_bottom).offset(6);
    }];
    
    
    _numberValueLabel = [UILabel lableWithSuperView:self.contentView font:UIFont_Px(14) color:UIColor_Hex(0x656565) title:@"" textAlignment:NSTextAlignmentLeft];
    [_numberValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleLabel);
        make.top.equalTo(numberLabel.mas_bottom).offset(6);
    }];
    
    
    UILabel *stateLabel = [UILabel lableWithSuperView:self.contentView font:UIFont_Px(14) color:UIColor_Hex(0x656565) title:@"状态".localizedString textAlignment:NSTextAlignmentLeft];
    [stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.centerY.equalTo(numberLabel);
    }];
    
    
    _stateValueLabel = [UILabel lableWithSuperView:self.contentView font:UIFont_Px(14) color:UIColor_Hex(0x656565) title:@"" textAlignment:NSTextAlignmentLeft];
    [_stateValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.centerY.equalTo(_numberValueLabel);
    }];
    
    
    UILabel *timeLabel = [UILabel lableWithSuperView:self.contentView font:UIFont_Px(14) color:UIColor_Hex(0x656565) title:@"时间".localizedString textAlignment:NSTextAlignmentRight];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-16);
        make.centerY.equalTo(stateLabel);
    }];
    
    
    _timeValueLabel = [UILabel lableWithSuperView:self.contentView font:UIFont_Px(14) color:UIColor_Hex(0x656565) title:@"" textAlignment:NSTextAlignmentRight];
    [_timeValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-16);
        make.centerY.equalTo(_stateValueLabel);
    }];
    
    
}

- (void)setDict:(NSDictionary *)dict {
    _dict = dict;
    
    _titleLabel.text = [self typeValue];
    _numberValueLabel.text = dict[@"num"];
    _stateValueLabel.text = [self stateValue];
    _timeValueLabel.text = dict[@"time"];
    _timeValueLabel.text = [_timeValueLabel.text substringToIndex:10];
}

- (NSString *)stateValue {
    int type = [_dict[@"state"] intValue];
    if (type == 0) return @"审核中".localizedString;
    if (type == 1) return @"已成功".localizedString;
    if (type == 2) return @"审核失败".localizedString;
    return @"";
}

- (NSString *)typeValue {
    int type = [_dict[@"type"] intValue];
    if (type == 0) return @"提币".localizedString;
    if (type == 1) return @"充币".localizedString;
    if (type == 2) return @"转入".localizedString;
    if (type == 3) return @"转出".localizedString;
    if (type == 4) return @"购买".localizedString;
    if (type == 5) return @"出售".localizedString;
    if (type == 6) return @"系统加币".localizedString;
    if (type == 7) return @"系统减币".localizedString;
    return @"";
}

@end
